home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-12-05 | 1.1 KB | 66 lines | [TEXT/MPS ] |
- c
- c This example inverts a string.
- c
- c Function INVERT
- c Takes a string argument.
- c Returns the argument with the letters in the reverse order.
- c
- c
- c Example provided for owners of Language Systems FORTRAN
- c © 1990 Language Systems Corp.
- c
- c Written by Steven Hopkins
- c
- string function INVERT(StrArg)
- implicit none
-
- C receive the argument by Descriptor
-
- structure /DescRec/
- pointer /character*1/ DataPtr
- integer*2 DataSize
- integer*2 SymT
- end structure
- record /DescRec/ StrArg
-
- C local declarations
-
- string result
- integer*4 limit,len
- pointer /byte/ strptr, argptr
-
- C set up pointer to the string argument
-
- argptr = StrArg.DataPtr
-
- C read the current length
-
- len = argptr^
-
- C set up pointer to the local result variable
-
- strptr = %loc(result)
-
- C copy the length byte into the result
-
- strptr^ = argptr^
- strptr = strptr + 1
-
- C point to the end of the argument
-
- argptr = argptr + len
-
- C store the argument character by character into the
- C local string
-
- limit = %loc(result) + len
- do while (strptr <= limit)
- strptr^ = argptr^
- argptr = argptr - 1
- strptr = strptr + 1
- end do
-
- C return the inverted string
-
- invert = result
- end